package com.zhaoxi.project.wms.controller;

import java.util.List;
import java.util.Map;

import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhaoxi.framework.aspectj.lang.annotation.Log;
import com.zhaoxi.framework.aspectj.lang.enums.BusinessType;
import com.zhaoxi.project.wms.domain.Process;
import com.zhaoxi.project.wms.service.impl.ProcessServiceImpl;
import com.zhaoxi.framework.web.BaseService;
import com.zhaoxi.framework.web.PageData;
import com.zhaoxi.common.utils.poi.ExcelUtil;
import com.zhaoxi.framework.web.page.TableDataInfo;

/**
 * 工序Controller
 *
 * @author zhaoxi
 * @date 2023-08-28
 */
@RestController
@RequestMapping("/wms/process")
public class ProcessController extends BaseService
{
    @Autowired
    private ProcessServiceImpl processService;

    /**
     * 查询工序分页列表
     */
    @PreAuthorize("@ss.hasPermi('wms:process:list')")
    @GetMapping("/getPage")
    public TableDataInfo getPage(Map map)
    {
        PageData pd = this.getPageData(map);
        startPage();
        List<PageData> list = processService.getList(pd);
        return getDataTable(list);
    }

    /**
     * 查询工序列表
     */
    @PreAuthorize("@ss.hasPermi('wms:process:list')")
    @GetMapping("/getList")
    public PageData getList(Map map)
    {
        PageData pd = this.getPageData(map);
        List<PageData> list = processService.getList(pd);
        return this.success(list);
    }



    /**
     * 获取工序详细信息
     */
    @PreAuthorize("@ss.hasPermi('wms:process:query')")
    @GetMapping(value = "/{id}")
    public PageData getInfo(@PathVariable("id") Long id)
    {
        return success(processService.getById(id));
    }

    /**
     * 新增工序
     */
    @PreAuthorize("@ss.hasPermi('wms:process:add')")
    @Log(title = "工序", businessType = BusinessType.INSERT)
    @PostMapping
    public PageData add(@RequestBody Map map)
    {
        PageData pd = this.getPageData(map);
        return this.success(processService.add(pd));
    }

    /**
     * 修改工序
     */
    @PreAuthorize("@ss.hasPermi('wms:process:edit')")
    @Log(title = "工序", businessType = BusinessType.UPDATE)
    @PutMapping
    public PageData edit(@RequestBody Map map)
    {
        PageData pd = this.getPageData(map);
        return toAjax(processService.edit(pd));
    }

    /**
     * 删除工序
     */
    @PreAuthorize("@ss.hasPermi('wms:process:remove')")
    @Log(title = "工序", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public PageData remove(@PathVariable Long[] ids)
    {
        return toAjax(processService.delByIds(ids));
    }

    /**
     * 新增物品工序关联
     */
    @PreAuthorize("@ss.hasPermi('wms:process:add')")
    @Log(title = "物品工序关联", businessType = BusinessType.INSERT)
    @PostMapping("/BomProcess")
    public PageData addBP(@RequestBody Map map)
    {
        PageData pd = this.getPageData(map);
        return this.success(processService.addBP(pd));
    }

    /**
     * 查询物品工序列表
     */
    @PreAuthorize("@ss.hasPermi('wms:process:list')")
    @GetMapping("/getBomProcessList")
    public PageData getBPList(Map map)
    {
        PageData pd = this.getPageData(map);
        List<PageData> list = processService.getBPList(pd);
        return this.success(list);
    }

    /**
     * 修改物品工序列表
     */
    @PreAuthorize("@ss.hasPermi('wms:process:edit')")
    @Log(title = "工序", businessType = BusinessType.UPDATE)
    @PutMapping("/BomProcess")
    public PageData editBP(@RequestBody Map map)
    {
        PageData pd = this.getPageData(map);
        return toAjax(processService.editBP(pd));
    }

    /**
     * 删除物品工序
     */
    @PreAuthorize("@ss.hasPermi('wms:process:remove')")
    @Log(title = "工序", businessType = BusinessType.DELETE)
    @DeleteMapping("/BomProcess")
    public PageData removeBP(Map map)
    {
        PageData pd = this.getPageData(map);
        return toAjax(processService.delBP(pd));
    }
}
